package com.mercury.service;

import com.alibaba.fastjson.JSONObject;
import com.mercury.dao.IPcclassroominfoDao;
import com.mercury.entity.Pcclassroominfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PcclassroominfoService {


    @Autowired
    IPcclassroominfoDao pcclassroominfoDao;

    public List<Pcclassroominfo> SearchAvailablePcclassroominfos(JSONObject json) {
        return pcclassroominfoDao.SearchAvailablePcclassroominfos(
                json.getString("SchoolId"),
                json.getString("ClassID"),
                json.getString("Time"),
                json.getString("TimeCate"),
                json.getInteger("AvailableVolume"));
    }

    public List<Pcclassroominfo> searchTimeCate(JSONObject json) {
        return pcclassroominfoDao.searchTimeCate(json.getString("SchoolGuid"), json.getString("ClassGuid"));
    }

    public List<Pcclassroominfo> searchTime(JSONObject json) {
        return pcclassroominfoDao.searchTime(json.getString("SchoolGuid"), json.getString("ClassGuid"), json.getString("TimeCate"));
    }

    public boolean PreCheckBuy(JSONObject json) {
        Pcclassroominfo pcclassroominfo = pcclassroominfoDao.PreCheckBuy(json.getString("ClassRoomGuid"));
        return pcclassroominfo.getMax() - pcclassroominfo.getSold() > 0;
    }

    public Pcclassroominfo GetBillInfo(JSONObject json) {
        return pcclassroominfoDao.GetBillInfo(json.getString("Guid"));
    }
}
